package com.ruoyi.common.utils;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTCreator;
import com.auth0.jwt.algorithms.Algorithm;

import java.util.Date;
import java.util.Map;

public class jwtUtils {

    private static String AlgorithmValue="jsdfsdfDFDfsd2343dfFDF";

    public static String getToken(Map<String, Object> map) {
        String token;
        JWTCreator.Builder builder = JWT.create();
        for(Map.Entry<String,Object> tmp :map.entrySet()){
            builder.withClaim(tmp.getKey(),tmp.getValue().toString());
        }
        builder.withExpiresAt(new Date(System.currentTimeMillis() + 1000*60*60*24*30*12));//TOKEN12个月有效期
        token=builder.sign(Algorithm.HMAC256(AlgorithmValue));
        return token;
    }
}
